
/**
 * @param {number} k
 * @param {number} n
 * @return {number[][]}
 */
 let res = []
 let path = []
 var combinationSum3 = function (k, n) {
   res = []
   backtracking(n, k, 0, 1)
   return res
 };
 const backtracking = (target, k, sum, startIndex) => {
   if (sum > target) { // 剪枝
     return;
   }
   if (path.length === k) {
     if (target === sum) res.push([...path])
     return
   }
   for (let i = startIndex; i <= 9 - (k - path.length) + 1; i++) {
     sum += i
     path.push(i)
     backtracking(target, k, sum, i + 1)
     sum -= i // 回溯
     path.pop() // 回溯
   }
 }